package com.medical.logback.controller;

import com.medical.logback.entity.Student;
import com.medical.logback.response.Result;
import com.medical.logback.service.TestServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Auther:gzf
 * @Date : 2022/06/23
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {

    @Resource
    private TestServiceImpl testService;

    @GetMapping("/testOne")
    public Result testOne() {
        testService.testOne();
        return Result.success();
    }

    @GetMapping("/testT")
    public Result testT(String name) {

        return Result.success(testService.testT(name));
    }

    @PostMapping("/postTest")
    public Result postTest(@RequestBody Student student) {
        return Result.success(testService.postTest(student));
    }

    /**
     * 出现异常不影响主流程运行
     */
    @GetMapping("/exceptionTest")
    public Result exceptionTest() {
        testService.exceptionTest();
        return Result.success();
    }

    /**
     * 出现异常需要回滚
     */
    @GetMapping("/exceptionRollBack")
    public Result exceptionRollBack() {
        testService.exceptionRollBack();
        return Result.success();
    }

    /**
     *
     */
    @GetMapping("/bizException")
    public Result bizException() {
        testService.BizException();
        return Result.success();
    }
    /**
     *
     */
    @GetMapping("/requestHttpUrl")
    public Result requestHttpUrl() {
        testService.requestHttpUrl();
        return Result.success();
    }
}
